<script type="text/javascript" src="__PUBLIC__/js/ajaxupload.3.6.js"></script>
<script type= "text/javascript">
	var now_PageCount = 1;
	var limit = '{$limit}';
    /*<![CDATA[*/
    $(document).ready(function(){
        var button		=	$('#ajax_upload_attach_button');
        var process		=	$('#ajax_upload_attach_process');
        $('#ajax_upload_attach_button').attr('disabled',false).html('{$l_button}').addClass('btn_b');
        new AjaxUpload(button,{
            action: '__ROOT__/index.php?app=home&mod=Attach&act=ajaxUpload&type={$type}&token={:jiami($allow_exts)}',
            name: 'myfiles',
			text: '上传文件',
            onSubmit : function(file, ext){
                this.disable();
                process.val('{$l_loading}');
            },
            onComplete: function(file, response){
                //alert(response);
                process.val('{$l_success}');
                this.enable();

                //处理上传后的过程
                var responseData	=	eval('('+response+')');
                //alert(response);
                //alert(responseData.status);
                //上传失败
                if(responseData.status==false){
                    //弹出错误信息
                    alert(responseData.info);
                    //上传成功
                }else{
                    //执行callback
					if(limit != 0 && now_PageCount > limit){
						alert("{:L('upload_attach_allow')}");
						return ;
					}
					++ now_PageCount;
                    {$callback}(responseData.info[0]);
                }
            }
        });

    });
    /*]]>*/
</script>
<script type= "text/javascript">
	function subPageCount(){
		now_PageCount--;
	}
	
	function setLimit(data){
		limit = data;
		now_PageCount = 0;
	}
	function deleteAttach(attach){
		if(confirm('{:L('upload_attach_delete')}')){
			subPageCount();
			$('#attach_upload_data .attach'+attach).remove();
		}
	}

<if condition="$callback eq 'attach_upload_success'">
	//执行默认的callback方法
	function attach_upload_success(info){
		var attachInfo = '<input class="attach'+info.id+'" type="hidden" name="attach[]" value="'+info.id+'|'+info.name+'"/>'+'<p><a class="attach'+info.id+'" href= javascript:void(0) onclick="deleteAttach('+info.id+')">[ 删除 ]</a>&nbsp;<span class="attach'+info.id+'"> '+info.name+'</span></p>';
		$('#attach_upload_data').append(attachInfo);
	}
</if>
</script>
<div id="attach_upload_widget">
  <div id="attach_upload_data" class="lh25">
    <volist id="vo" name="editdata">
      <input type="hidden" value="{$vo.id}|{$vo.name}" name="attach[]" class="attach{$vo.id}"/>
      <p> <a onclick="deleteAttach({$vo.id})" href="javascript:void(0)" class="attach{$vo.id}">[ {:L('common_delete')} ]</a> <span class="attach{$vo.id}">{$vo.name}</span> </p>
    </volist>
  </div>
  <div id="attach_upload_tool">
    <div class="L">
      <input class="in_put mr5" style="_margin-right:10px;" id="ajax_upload_attach_process" disabled="disabled" />
      <button class="btn_sea" id="ajax_upload_attach_button" disabled="disabled">{:L('upload_attach_loading')}</button>
    </div>
    <div class="di_wei L ml5 pt5"> <img alt="{:L('upload_attach_alt')}" src="__PUBLIC__/themes/blue/images/doubt_Icon.gif" onmouseover="$('#ajax_attach_help').show()" onmouseout="$('#ajax_attach_help').hide()" />
      <div class="clewbox" id="ajax_attach_help" style="display:none;">
        <div class="clewbox_bg">{:L('upload_attach_info')}：</div>
        <div class="clewbox_bg_b"> {$allow_exts} </div>
      </div>
    </div>
    <div class="C"></div>
  </div>
</div>